package com.example.OpenGLES320;

import android.opengl.GLES30;

public class GLUniformManager {
    private GLUniformManager() {}
    private static GLUniformManager m_manager;

    public static GLUniformManager instance() {
        if(m_manager == null){
            m_manager = new GLUniformManager();
        }
        return m_manager;
    }

    /**
     * @brief 设置mat4 float元素类型的uniform
     * @param shaderID 着色器ID
     * @param uniformName 统一变量的名称
     * @param matrix 矩阵（必须是列主序）
     */
    public void setUniformMatrix4fv(int shaderID, String uniformName, float[] matrix){
        int mvpMatrixLocation = GLES30.glGetUniformLocation(shaderID, uniformName);
        GLES30.glUniformMatrix4fv(mvpMatrixLocation, 1, false, matrix, 0);
    }
}
